-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new type support in query_as #2369
Conversation
4166e9f
to
f99264f
Compare
There was a reason I didn't do this and I believe it had to do with compile errors. Can you test what happens when you try to use an incompatible type? |
I'll try to add some type checking to make errors more obvious. The current error looks like this:
|
Yeah, neither error is great. Something I want to do shortly but won't make the 0.7.0 release is rewrite the typechecking code entirely so that it also works with |
Yes please! Both using |
The annoying part is that As-implemented, I think that macro would trigger |
I suppose concatenation isn't really necessary as I could just emit two different const _: () = panic!("field `foo` of struct `Bar` expected type `i32`");
const _: () = panic!("column `foo` of query has SQL type `TEXT`"); gives something like:
The formatting isn't ideal but at least all the relevant information is there. |
Is this feature supposed to work for |
For future travellers, these sqlx docs solved my problem. Basically: #[derive(sqlx::Type)]
#[sqlx(transparent)]
struct UserId(i64); |
fixes #2173
This change shouldn't break anything, because
From<T>
is implemented forT
.Maybe we can also use
From
for binded arguments insqlx::query
example:
Here we can use
t.into()
internally, but it can break inference